﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2
{
    class 鸭子叫
    {
            interface ISwimable
    {
        void Swimming();
    }

    interface IShoutable
    {
        void Shouting();
    }


    class RealDuck : ISwimable, IShoutable
    {
        public RealDuck()
        { }

        public void Swimming()
        {
            Console.WriteLine("真实的鸭子能够在水中快速的游玩！");
        }

        public void Shouting()
        {
            Console.WriteLine("真实的鸭子叫声是：嘎`嘎`嘎`嘎`嘎`嘎");
        }
    }


    class RubberDuck : ISwimable, IShoutable
    {
        public RubberDuck()
        { }

        public void Swimming()
        {
            Console.WriteLine("橡皮的鸭子能够在水中慢慢的游！");
        }

        public void Shouting()
        {
            Console.WriteLine("橡皮的鸭子叫声是：唧`唧`唧`唧`唧`唧");
        }
    }


    class WoodDuck : ISwimable
    {
        public WoodDuck()
        { }

        public void Swimming()
        {
            Console.WriteLine("木头的鸭子能够在水中轻轻的游！");
        }
    }
        class DonaldDuck : ISwimable, IShoutable
        {
            public DonaldDuck()
            { }

            public void Swimming()
            {
                Console.WriteLine("唐老鸭在水里想怎么游泳就怎么游泳！");
            }

            public void Shouting()
            {
                Console.WriteLine("唐老鸭可以说：嘿！米老鼠，你在干嘛？");
            }
        }


        class Factory
    {

        public static ISwimable CreateSwiming(string name)
        {
            switch (name)
            {
                case "1": return new RealDuck();
                case "2": return new RubberDuck();
                case "3": return new WoodDuck();
                case "4":return new DonaldDuck();
                default:
                    throw new Exception("系统找不到您选择的鸭子！");
            }

        }


        public static IShoutable CreateShouting(string name)
        {
            switch (name)
            {
                case "1": return new RealDuck();
                case "2": return new RubberDuck();
                case "4": return new DonaldDuck();
                    default:
                    throw new Exception("系统找不到您选择的鸭子！");
            }
        }
    }

    static void Main(string[] args)
    {

        while (true)
        {
            Console.WriteLine("请选择您要查看的鸭子，如下：");
            Console.WriteLine("1、真实鸭子 2、橡皮鸭子 3、木头鸭子 4、唐老鸭" );
            string name = Console.ReadLine();

            if (name == "1" || name == "2" || name == "3" ||name == "4")
            {
                if (name != "3")
                {

                    IShoutable shout = Factory.CreateShouting(name);
                    shout.Shouting();
                }

                ISwimable swim = Factory.CreateSwiming(name);
                swim.Swimming();
                Console.WriteLine();
                continue;
            }
            Console.WriteLine("系统找不到您选择的鸭子……");
        }
    }
}

}





